package com.example.consumer;

import feign.FeignException;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author weiZhiLin
 * @version 1.0
 * @date 2021/6/23 16:10
 */
@Component
public class ProviderBack implements FallbackFactory<FeinApi> {
    @Override
    public FeinApi create(Throwable cause) {
        return new FeinApi() {
            @Override
            public String getPort() {
                System.out.println(cause);
                if (cause instanceof FeignException.InternalServerError) {
                    return "服务器500！";
                }
                return "咕咕咕";
            }
        };
    }
}
